package com.nettytime.util.testjiebaonianbao;
import com.nettytime.entity.UserSocket;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import java.time.LocalDateTime;

public class EchoClientHandler extends SimpleChannelInboundHandler<UserSocket> {
    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        ctx.write(getUser());
    }
    private UserSocket getUser() {
        UserSocket user = new UserSocket();
        user.setTopicName("sfafasa");
        user.setHeaderName("zhangxufeng");
        user.setNote("zhangxufeng");
        user.setStatus(0);
        user.setCreateTime(LocalDateTime.now());
        return user;
    }
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, UserSocket user) throws Exception {
        System.out.println("receive message from server: " + user);
    }


}